<?php

/**
 * ECTouch Open Source Project
 * ============================================================================
 * Copyright (c) 2012-2014 http://ectouch.cn All rights reserved.
 * ----------------------------------------------------------------------------
 * 文件名称：cardControoller.class.php
 * ----------------------------------------------------------------------------
 * 功能描述：活动控制器
 * ----------------------------------------------------------------------------
 * Licensed ( http://www.ectouch.cn/docs/license.txt )
 * ----------------------------------------------------------------------------
 */
/* 访问控制 */
defined('IN_ECTOUCH') or die('Deny Access');

class CardController extends CommonController {

    private $size = 10;
    private $page = 1;
    private $cat_id = 0;
    private $keywords = '';

    public function __construct() {
        parent::__construct();
    }

    /* ------------------------------------------------------ */

    //-- 活动分类
    /* ------------------------------------------------------ */
    public function index() {
        
    }

    /* ------------------------------------------------------ */

    //-- 活动列表
    /* ------------------------------------------------------ */
    public function card_list() {		
       
    }

    /**
     * 活动列表异步加载
     */
    public function asynclist() {
        
    }

    /* ------------------------------------------------------ */
    //-- 活动详情
    /* ------------------------------------------------------ */
    public function info() {
		$user_id = intval($_GET['id']);

		/* 微信分享设置 */
		$res = array();		
		$wxinfo   = model('Base')->model->table('wechat')->field('token, appid, appsecret')->find();
        $appid    = $wxinfo['appid'];
        $secret   = $wxinfo['appsecret'];
        
		//微信JS SDK
        $jssdk = new Jssdk($appid, $secret);
        $signPackage = $jssdk->GetSignPackage();

        $res['appid'] = $signPackage["appId"];
        $res['timestamp'] = $signPackage["timestamp"];
        $res['noncestr'] = $signPackage["nonceStr"];
        $res['signature'] = $signPackage["signature"];
		//
        $this->assign('res', $res);

		//微信头像
		$wechat_pic= model('Base')->model->table('wechat_user')->field('headimgurl')->where(array('ect_uid'=>$user_id))->getOne();
        //后台添加的头像
		$user_pic= "http://vip.siinfo.cn/".model('Base')->model->table('users')->field('user_pic')->where(array('user_id'=>$user_id))->getOne();
		if($wechat_pic){
		$user_pic=$wechat_pic;
		}

		//手机号
		$mobile_phone= model('Base')->model->table('users')->field('mobile_phone')->where(array('user_id'=>$user_id))->getOne();
		//真实姓名
		$user_name= model('Base')->model->table('reg_extend_info')->field('content')->where(array('user_id'=>$user_id,'reg_field_id'=>100))->getOne();
		//微信号
		$wechat_no= model('Base')->model->table('reg_extend_info')->field('content')->where(array('user_id'=>$user_id,'reg_field_id'=>101))->getOne();
		//公司
		$company= model('Base')->model->table('reg_extend_info')->field('content')->where(array('user_id'=>$user_id,'reg_field_id'=>102))->getOne();
		//职务
		$position= model('Base')->model->table('reg_extend_info')->field('content')->where(array('user_id'=>$user_id,'reg_field_id'=>103))->getOne();
        //标签
		$user_tag= model('Base')->model->table('reg_extend_info')->field('content')->where(array('user_id'=>$user_id,'reg_field_id'=>104))->getOne();
        //简介 
 		$user_desc= model('Base')->model->table('reg_extend_info')->field('content')->where(array('user_id'=>$user_id,'reg_field_id'=>105))->getOne();

		//分享描述
		$wechat_desc="手机:".$mobile_phone." | ".
			         "公司:".$company." | ".
			         "职务:".$position;

		$card['title']=$user_name."的名片";
        $card['name']=$user_name;		
		$card['company']=$company;
        $card['wechat_no']=$wechat_no;
		$card['wechat_desc']=$wechat_desc;
		$card['mobile_phone']=$mobile_phone;
		$card['position']=$position;
		$card['desc']=$user_desc;
		$card['file_url']=$user_pic;
        $card['url']="http://vip.siinfo.cn/?c=card&a=info&id=".$user_id;
        $this->assign('title', L('profile'));
        $this->assign('card', $card);
        $this->display('card_info.dwt');
    }

	/**
	* 添加收藏
	*/
	public function collect_add(){
           
	}

    /**
	* 取消收藏
	*/
	public function collect_del(){
           
	}

	/**
	* 发表评论
	*/
	public function comment_add(){
		
	}

	/**
     * 名片评论
     */
    public function comment_list()
    {
        
    }
    
    /**
     * 处理参数便于搜索名片信息
     */
    private function parameter() {
      
    }

}